<?php
$tag = db::q( "SELECT * FROM `tags`" );
while ( $tag->exists() ) {
  $name = db::q( "SELECT * FROM `tags_names` WHERE `id`=':1'", $tag->name );
  db::q( "UPDATE `tags` SET `tag_name`=':2', `tag_link`=':3' WHERE `id`=':1'", $tag->id, $name->name, $name->permalink );
  var_dump(db::$last);
  $tag->next();
}

?>